package com.soft.security.action;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.soft.core.action.BaseAction;
import com.soft.core.dao.GenericDao;
import com.soft.security.dao.DeptDao;
import com.soft.security.domain.Dept;

@Controller("deptAction")
@Scope("prototype")
public class DeptAction extends BaseAction<Dept> {

	private DeptDao deptDao;
	
	@Resource
	public void setDeptDao(DeptDao deptDao) {
		this.deptDao = deptDao;
	}

	@Override
	public GenericDao<Dept> getDao() {
		return deptDao;
	}
	
	@Override
	public void beforFind(DetachedCriteria criteria) {
		if (null != model.getDeptName() && !"".equals(model.getDeptName())) {
			criteria.add(Restrictions.like("deptName", model.getDeptName(),
					MatchMode.ANYWHERE));
		}
	}
	
}
